Debugging computer programs can be tedious and time-consuming, in part because the program code responsible for a bug can be difficult to find. A serious software bug may be caused by a single instruction among millions of instructions in a computer program. Such an instruction may be difficult or prohibitively costly to find by manually inspecting every instruction in the program. As a result, software programs known as “debuggers” have long been used to facilitate the process of debugging.
One useful feature of conventional debuggers is the ability to execute a program until the program accesses a predetermined memory location. When the program accesses the predetermined memory location, the debugger halts execution of the program. This feature may be useful when it is suspected that the program is storing an incorrect value in the memory location or otherwise accessing the memory location in a way that is causing the program to malfunction. Halting execution of the program at this point enables the programmer to inspect the contents of the predetermined memory location in an attempt to identify the source of the bug being investigated.
Modern microprocessors typically include special “watchpoint registers” provided specially for use by debugger software in the circumstances described above. To execute a program until a predetermined range of memory locations is accessed, the debugger stores the range of addresses in a pair of watchpoint registers and then executes the program. When the program accesses a memory location in the predetermined range, a “watchpoint trap” is generated, which causes control to pass to the debugger. Providing this functionality directly in the hardware of the microprocessor enables programs being debugged to be executed much more rapidly than if such functionality were implemented in software. The number of watchpoints, however, is limited by the number of watchpoint registers in the processor.